{include file='common/header' /}
<div class="col-md-12">
    <h3>
        <span>角色管理</span>
        <a href="{:url('add',['group'=>''])}"><span class="glyphicon glyphicon-plus"></span></a>
    </h3>
    <div class="table-responsive">
        <table class="table table-bordered table-hover table-ebcms">
            <tbody>
                <tr>
                    <th style="width: 80px;">排序</th>
                    <th style="width: 90px;">操作</th>
                    <th style="width: 170px;">权限</th>
                    <th style="width: 60px;">状态</th>
                    <th>名称</th>
                </tr>
                {php}
                    $data = \think\Db::name('auth_group')->order('sort desc,id asc') -> select();
                    $data = \ebcms\Tree::group($data);
                {/php}
                {foreach name='data' item='items' key='group'}
                    <tr>
                        <th>{$group}</th>
                        <th colspan="5">
                            <a href="{:url('add?group='.$group)}" class="btn btn-primary btn-sm">添加</a>
                        </th>
                    </tr>
                    {foreach name='items' item='vo'}
                        <tr>
                            <td>
                                <input value="{$vo.sort}" class="form-control input-sm ebcms-change" url="{:url('resort')}" data-id="{$vo.id}">
                            </td>
                            <td>
                                {if condition="check_auth('edit')"}
                                <a href="{:url('edit?id='.$vo['id'])}" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-pencil"></span></a>
                                {/if}
                                {if condition="check_auth('delete')"}
                                <button type="button" class="btn btn-primary btn-sm ebcms-do" url="{:url('delete')}" data-ids='{$vo.id}' confirm="删除后不可恢复，确定删除？"><span class="glyphicon glyphicon-remove"></span></button>
                                {/if}
                            </td>
                            <td>
                                {if condition="check_auth('rule')"}
                                <a href="{:url('rule?id='.$vo['id'])}" class="btn btn-primary btn-sm">功能权限</a>
                                {/if}
                                {if condition="check_auth('menu')"}
                                <a href="{:url('menu?id='.$vo['id'])}" class="btn btn-primary btn-sm">导航权限</a>
                                {/if}
                            </td>
                            <td>
                                {if condition="check_auth('status')"}
                                    {eq name='vo.status' value='1'}
                                    <button type="button" class="btn btn-primary btn-sm ebcms-do" url="{:url('status')}" data-ids='{$vo.id}' data-value='0'><span class="glyphicon glyphicon-ok-sign"></span></button>
                                    {else/}
                                    <button type="button" class="btn btn-warning btn-sm ebcms-do" url="{:url('status')}" data-ids='{$vo.id}' data-value='1'><span class="glyphicon glyphicon-ban-circle"></span></button>
                                    {/eq}
                                {/if}
                            </td>
                            <td>{$vo.title}</td>
                        </tr>
                    {/foreach}
                {/foreach}
            </tbody>
        </table>
    </div>
</div>
{include file='common/footer' /}